package Collection.Set;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class HashSetDemo {
    public static void main(String[] args) {
        Set<String>  hashSet = new HashSet<>();
        hashSet.add("a");
        hashSet.add("b");
        hashSet.add("c");
        hashSet.add("d");
        hashSet.add("a");
        hashSet.add("d");
        Iterator<String> iterator = hashSet.iterator();
        while(iterator.hasNext()){
            String element = iterator.next();
            System.out.println(element);
        }
        System.out.println("---------");
        //for循环 只有增强for循环
        for(String str : hashSet){
            System.out.println(str);
        }
    }
}
